fix(security): constrain WHIP/WHEP path params to prevent log injection - #306
Open
birme wants to merge 1 commit into
Open
fix(security): constrain WHIP/WHEP path params to prevent log injection#306birme wants to merge 1 commit into
birme wants to merge 1 commit into
Conversation
The username, lineId and productionId path params on the WHIP/WHEP POST
routes were URL-decoded and interpolated into log messages without any
sanitization, allowing newline/CR/ANSI injection to forge log entries.
Add restrictive TypeBox patterns: numeric-only (^[0-9]+$) for productionId
and lineId (consistent with api_productions.ts), and ^[\w .-]{1,200}$ for
username. A literal space is used instead of \s so control chars such as
\n and \r are rejected. Adds regression tests.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
username,lineIdandproductionIdpath params onPOST /api/v1/whip/:productionId/:lineId/:usernameand the WHEP equivalent were URL-decoded by Fastify and interpolated directly into log messages with no sanitization, allowing newline (%0a), carriage-return (%0d) and ANSI-escape (%1b[...) injection to forge or corrupt log entries.patternconstraints on both routes: numeric-only^[0-9]+$forproductionIdandlineId(matching the existing convention inapi_productions.ts, and correct since line/production ids are generated as numeric strings), and^[\w .-]{1,200}$forusername.\s, because\salso matches\n/\r/\t— the exact control characters this fix must reject. Requests carrying control chars now fail schema validation with a 400 before anything is logged.Test plan
npm test) — 245 passed (2 new)npm run typecheck)npm run lint) — 0 errorsCloses #287
🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com